package com.eazy.lkv2.web.controller.mobile.activity;

import com.eazy.lkv2.web.entity.Activitys;
import com.eazy.lkv2.web.service.activity.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.eazy.lkv2.web.controller.BaseController;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author ywj
 * @date 2016.9.8
 * @desc 手机端活动列表
 */
@Controller
@RequestMapping("activity")
public class ActivityController extends BaseController<Object, Integer> {

    @Autowired
    private ActivityService activityService;

    @RequestMapping(value = "newactivitys.html", method = RequestMethod.GET)
    public String activitys(Model model) {
        model.addAttribute("activityData", activityService.select());
        return getDefault("activity/activitys");
    }

    @RequestMapping(value = "/details.html/{id}", method = RequestMethod.GET)
    public String activitysDetail(@PathVariable("id") String id, Model model) {
        Activitys activity = activityService.findById(Integer.parseInt(id));
        model.addAttribute("activity", activity);
        return "mobile/activity/activity_detail";
    }

}
